package com.woniuxy.springsecurity.controller;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author author
 * @Create 2023-10-26 15:32
 */
@RestController
public class MyController {

    //Controller的请求路径方法添加这个注解
    //hasAnyAuthority('参数')和数据库中查询的名字做比较
    @PreAuthorize("hasAnyAuthority('test')")
    @RequestMapping("/test")
    public String test(){
        return "test";
    }

    @PreAuthorize("hasAnyAuthority('add')")
    @RequestMapping("/add")
    public String add(){
        return "add";
    }
}
